/**
* Oxide
*
* Copyright (c) 2011 Dinosaur Kick Pty Ltd, All rights reserved.
*
* This source code is made available under the "Modified BSD" licensing arrangement.
* See license.txt for details.
*/
// ----------------------------------------------------------------------------
#include <functional>
#include <string>
// ----------------------------------------------------------------------------
#ifndef O2_IS_EMPTY_INC
#define O2_IS_EMPTY_INC
namespace o2 {
// ----------------------------------------------------------------------------

template <typename ValueT>
struct is_empty
	: public std::unary_function<ValueT, bool>
{
	bool operator() (const ValueT& value)
	{
		return static_cast<bool>(value);
	}
};

template <typename CharT, typename TraitsT, typename AllocT>
struct is_empty<std::basic_string<CharT, TraitsT, AllocT> >
	: public std::unary_function<std::basic_string<CharT, TraitsT, AllocT>, bool>
{
	bool operator() (const std::basic_string<CharT, TraitsT, AllocT>& value)
	{
		return value.empty();
	}
};

template <>
struct is_empty<char>
	: public std::unary_function<char, bool>
{
	bool operator() (char value)
	{
		return std::isspace(value);
	}
};

template <>
struct is_empty<wchar_t>
	: public std::unary_function<wchar_t, bool>
{
	bool operator() (wchar_t value)
	{
		return std::isspace(value);
	}
};

// ----------------------------------------------------------------------------
} // namespace o2
#endif // O2_IS_EMPTY_INC
// ----------------------------------------------------------------------------
